package com.guocheng.quartz.meet;

import com.guocheng.modules.meet.service.MeetService;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;


public class StatusJob extends QuartzJobBean {

    @Autowired
    private MeetService meetService;

    @Autowired
    private StatusQuartz statusQuartz;

    //检查所有会议状态
    @Override
    protected void executeInternal(JobExecutionContext jobDate) throws JobExecutionException {

        //状态检查
        JobDataMap date = jobDate.getMergedJobDataMap();

        //获取会议id
        Integer id = date.getInt("id");

        //获取状态
        Integer status = date.getInt("status");

        //会议结束删除jobkey
        if(status.intValue()==-1){
            statusQuartz.deleteJobKey(id);
        }

        //到点更新会议状态
        meetService.updateStatusById(id,status);
    }
}